strcpy(slist[i].fname,"free")

来源:百度知道 编辑:UC知道 时间:2024/05/30 21:07:20
char fname[50];strcpy(slist[i].fname,"free");cout<<slist[i].fname;输出结果不是free,空,为啥?
const int MAX=1000; //×î´ó·ÖÇø¸öÊýºÍ×÷Òµ¸öÊý
struct subarea{
int start;
int length;
char fname[50];
};

subarea slist[MAX];

#include<iostream>
using namespace std;

const int MAX=1000; //×?′ó·?????êyoí×÷òμ??êy
struct subarea{
int start;
int length;
char fname[50];
};

int main()
{
subarea slist[MAX];
char fname[50];
strcpy(slist[0].fname,"free");
cout<<slist[0].fname;
return 0;
}

怎么不是free啊 我试过了 没有问题 至于程序中你的i可能还有别的用处吧
程序是没有问题的

slist【i】是怎么定义的?
你的定义应该有问题。